/*
 * input.h
 *
 *  Created on: May 12, 2010
 *      Author: snirgaz
 */

#ifndef INPUT_H_
#define INPUT_H_
#include "../HelpLibs/def.h"
#include "../HelpLibs/QmcParameters.h"
#include "../HelpLibs/pugixml.hpp"
#include "boost/lexical_cast.hpp"
#include "yaml-cpp/yaml.h"

class InputFile {
private:
	string fileName_;
	QmcParameters qmcParameters_;
public:
	InputFile(string fileName);
	void readFile();
	QmcParameters& getQmcParams();
};

class KeyErrorExceptions: public exception {
	string missingkey_;
public:
	KeyErrorExceptions(string missingkey) :
			missingkey_(missingkey) {
	}
	virtual const char* what() const throw () {
		return (string("Missing Key") + missingkey_).c_str();
	}
	virtual ~KeyErrorExceptions() throw () {
	}
};
class YamlReader {
public:
	YamlReader(YAML::Node node) :
			node_(node) {
	}
	template<typename T>
	T read(string param) {
		if (node_[param]) {
			return node_[param].as<T>();
		} else
			throw KeyErrorExceptions(string("Missing Param ") + param);
	}
private:
	YAML::Node node_;

};
#endif /* INPUT_H_ */
